<?php

namespace app\index\model;

use think\Model;

class Asset_to_shot extends Model
{

    public function Assets()
    {
        return $this->belongsTo('Assets','assets_id', 'id');
    }

    public static function get_data()
    {
        $get_data = self::where(input())->with('Assets')->select()->toArray();
        $assets[]=array() ;
        foreach ($get_data as $key => $value) {
            // unset($value['assets']['id']) ;
            $assets[]=$value['assets'] ;
        }
        if($assets){
            return [1 , $assets];
        }else{
            return [0 , "not found"];
        }
    }

    public static function get_count($data='')
    {
        return self::where($data)->count();
    }

    public static function add_data()
    {
        $data_count = self::where(input())->count() ;
        if(!$data_count){
            return [1 ,self::strict(false)->insert(input())];
        }else{
            return [0 , "data is repeat"];
        } 
    }

    public static function update_data($data)
    {
        return self::update($data);
    }

     public static function delete_data($data='')
    {
        return self::where($data)->delete();
    }
}